import requests
from config import RunConfig

'''
任务管理-任务派遣单
'''

def task_export(id):
    '''
    任务派遣单导出
    :param id: 任务id
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/assignment/order/export/{id}",
        headers=RunConfig.headers,
        json={},
        verify=False
    )
    return response


def task_update(para):
    '''
    修改任务派遣单
    :param para: 项目信息
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/assignment/order/update",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def task_info(id):
    '''
    任务派遣单详情
    :param id: 任务id
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/assignment/order/info/{id}",
        headers=RunConfig.headers,
        json={},
        verify=False
    )
    return response


def task_search(project_name="", project_code="", property="",
                         project_type_id="", project_manager=""):
    '''
    分页查询任务派遣单
    :param project_name: 项目名称
    :param project_code: 项目编码
    :param property: 管控类型
    :param project_type_id: 勘测阶段
    :param project_manager: 项目负责人
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/assignment/order/page?page=1&perPage=10",
        headers=RunConfig.headers,
        json={
            "projectName": project_name,
            "projectCode": project_code,
            "property": property,
            "projectTypeId": project_type_id,
            "projectManager": project_manager
        },
        verify=False
    )
    return response
